Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: Add interface service_policy parameter #332

Open
wants to merge 6 commits into
base: integration/main
Choose a base branch
from

Conversation

acch
Copy link

@acch acch commented Oct 31, 2024

Adds ability to configure service_policy parameter of IP Interfaces.

Closes #306.

Acceptance tests pass:

$ TF_ACC=1 go test ./internal/provider/networking/network_ip_interface_resource_test.go -v
=== RUN   TestAccNetworkIpInterfaceResource
--- PASS: TestAccNetworkIpInterfaceResource (4.44s)
PASS
ok      command-line-arguments  4.449s
$ TF_ACC=1 go test ./internal/provider/networking/network_ip_interface_resource_alias_test.go -v
=== RUN   TestAccNetworkIpInterfaceResourceAlias
--- PASS: TestAccNetworkIpInterfaceResourceAlias (3.93s)
PASS
ok      command-line-arguments  3.935s

Example Terraform Configuration:

// sample IP Interface with service_policy parameter
resource "netapp-ontap_networking_ip_interface" "example" {
  cx_profile_name = ...
  name            = ...
  svm_name        = ...
  ...
  service_policy   = "default-management"
}

@acch acch force-pushed the 306-interface-service_policy-parameter branch 2 times, most recently from 71823b2 to 1de03df Compare October 31, 2024 12:40
@acch acch marked this pull request as ready for review October 31, 2024 13:16
@carchi8py carchi8py added the enhancement New feature or request label Oct 31, 2024
@carchi8py carchi8py added this to the 2.1 milestone Oct 31, 2024
@acch acch force-pushed the 306-interface-service_policy-parameter branch from d2aa5ab to 2552062 Compare November 4, 2024 09:17
@acch acch force-pushed the 306-interface-service_policy-parameter branch from 39b39bc to dd0999b Compare December 9, 2024 14:23
* "default-management" if scope is cluster and IPspace is not Cluster (not yet implemented)
* "default-cluster" if scope is cluster and IPspace is Cluster (not yet implemented)
*/
Default: stringdefault.StaticString("default-data-files"),
Copy link
Contributor

@chuyich chuyich Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ONTAP 9.6 API document:
If not specified in POST, the following default property values are assigned:
:
service_policy:
default-data-files if scope is svm
default-management if scope is cluster and IPspace is not Cluster
default-cluster if scope is svm and IPspace is Cluster

The default value can be found in query API. And it does not have to be set in the POST API call. So, it should not be set here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @chuyich, thank you very much for reviewing this PR.

I did add a default value for the following reason: without a default value, when there is no configuration supplied, Terraform will mark the attribute as unknown. Unknown attributes are constantly displayed as "(known after apply)" in plan outputs... the default value is to reduce these "(known after apply)" plan outputs.

I'm happy to remove the default value, though - just wanted to double-check that the behavior mentioned above is indeed desired in this case.

Thanks much for a quick confirmation!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it could be one of 3 values based on the scope, set any of them may not be correct. It's better to use this way:
https://github.com/NetApp/terraform-provider-netapp-ontap/blob/integration/main/internal/provider/name_services/name_services_ldap_resource.go#L106
PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), },
We found setting default values may cause issues in some cases. The above will cover the case you mentioned. Also after you remove the default value part, the parameter handling needs to be adjusted accordingly. You may use the above case as a reference.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I've removed the default value, and added logic for fetching the value computed by ONTAP API instead.

Copy link
Contributor

@chuyich chuyich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In resource, the field service_policy should not be set default value at the beginning. Based on the API (9.6) document, this field does not have to be set in the POST API call. Please make change accordingly.

Copy link
Contributor

@carchi8py carchi8py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing updates to the documentation pages for the new options.

@acch acch force-pushed the 306-interface-service_policy-parameter branch from dd0999b to 57fc48c Compare January 7, 2025 10:40
@acch
Copy link
Author

acch commented Jan 7, 2025

Thanks @carchi8py and @chuyich for your feedback!

I've removed the default value for service_policy, and added logic for fetching the value computed by ONTAP API instead. I've also updated the documentation for the new parameter, and verified that acceptance tests (still) pass.
Please let me know if this is acceptable, or what is missing.

Thanks much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 2.1
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add interface service_policy parameter
3 participants